package com.ky.manage.utils;

/**
 * 判断是否重复单击的helper
 *
 * @author zhaoyan
 * @date 2019-11-25
 */
public class ReClickHelper {
    private static long currentTime;

    /**
     * 单击时间间隔在500内，返回false；大于500，返回true
     *
     * @return
     */
    public static boolean clickEnable() {
        boolean clickEnable = true;
        if (Math.abs(System.currentTimeMillis() - currentTime) < 500) {
            clickEnable = false;
        }
        currentTime = System.currentTimeMillis();
        return clickEnable;
    }

    public static boolean clickEnable(long interval) {
        boolean clickEnable = true;
        if (Math.abs(System.currentTimeMillis() - currentTime) < interval) {
            clickEnable = false;
        } else {
            currentTime = System.currentTimeMillis();
        }
        return clickEnable;
    }

}